import {get,post} from '../../utils/request.js'
const state = {
    //用来保存查询出来的资讯信息
    news_classification:[],
}

const actions = {
  //查询所有资讯信息
  findAllNews(context){
    //异步操作
    get('/category/findAll').then(res =>{
      let response = res.data
      context.commit('SET_NEWS_CLASSIFICATION',response)
    })
  },
  //保存栏目信息
  saveNews(context,form){
    let response = post('/category/saveOrUpdate',form)
    return response
  },
  //删除栏目信息
  deleteNews(context,id){
    let response = get('/category/deleteById',id)
    return response
  }
}

const mutations = {
  //修改state中的值
  SET_NEWS_CLASSIFICATION(state,response){
    state.news_classification = response
  }
}

export default {
  namespaced:true,
  state,
  actions,
  mutations
}
